package com.yhao.feign.controller;

import com.yhao.feign.bean.User;
import com.yhao.feign.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @Autowired
    HelloService helloService;

    @RequestMapping(value = "/feign-consumer", method = RequestMethod.GET)
    public String helloConsumer() {
        return helloService.hello();
    }


    @RequestMapping(value = "/feign-consumer2")
    public String helloConsumer2() {
        StringBuilder sb = new StringBuilder();
        sb.append(helloService.hello()).append("\n\t");
        sb.append(helloService.hello("name1")).append("\n\t");
        sb.append(helloService.hello("name2", 12)).append("\n\t");
        sb.append(helloService.hello(new User("name3",13))).append("\n\t");
        return sb.toString();
    }
}
